<template>
    <!-- 添加或修改采购单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
        <el-table :data="tableData" style="width: 100%" height="550">
            <el-table-column prop="title" label="题目类型" width="180">
            </el-table-column>
            <el-table-column prop="problem" label="题目" width="180">
            </el-table-column>
            <el-table-column prop="correctAnswer" label="正确答案">
            </el-table-column>
            <el-table-column prop="answer" label="学员选择">
            </el-table-column>
        </el-table>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="cancel">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>
<script>
import { listExamResRecord } from "@/api/training/examRes";

export default {
    name: "Order",
    data() {
        return {
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 表单参数
            tableData: []
        };
    },
    created() {

    },
    methods: {
        // 取消按钮
        cancel() {
            this.open = false;
        },
        /** 新增按钮操作 */
        handleShow(data) {
            this.open = true;
            this.tableData = [];
            this.title = "查看答题记录";
            listExamResRecord({
                userId: data.userId,
                planId: data.planId
            }).then(res => {
                if(res.code == 200) {
                    let {params} = res.rows[0];
                    let dataList = [];
                    
                    console.log(params.examRes.questions_map);
                    
                    params.examRes.questions_map.forEach(e => {
                        console.log(e);
                        let {title} = e;
                        e.questions.forEach(q => {
                            let {answer,correctAnswer,problem} = q
                            dataList.push({title,answer,correctAnswer,problem})
                        })
                    })
                    this.tableData = dataList;
                    console.log(dataList);
                    
                }
            })
        }
    }
};
</script>